﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
    var pid = ViewBag.PId;
}
<script>
    $(function () {
        top.clients.dataItems["QuestionType"] = { "-1": "所有", 1: "单选", 2: "多选", 3: "评分", 4: "问答" };
        gridList();
        var pid = '@pid';
        $.ajax({
            url: "/Questionnaire/QnPaper/GetFormJson",
            data: { keyValue: pid },
            dataType: "json",
            async: false,
            success: function (data) {
                $("#form1").formSerialize(data);
            }
        });
    });
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Questionnaire/QnQuestion/GetStatisticsJson",
            height: $(window).height() - 128,
            postData: {
                keyword: $("#txt_keyword").val(),
                pid: '@pid',
                type: -1,
                state: -1
            },
            colModel: [
                { label: "主键", name: "F_QuestionId", hidden: true, key: true },
                { label: '题目', name: 'F_Question', width: 300, align: 'left' },
                {
                    label: '题型', name: 'F_Type', width: 80, align: 'left',
                    formatter: function (cellvalue) {
                        return top.clients.dataItems["QuestionType"][cellvalue] == undefined ? "" : top.clients.dataItems["QuestionType"][cellvalue];
                    }
                },
                { label: '排序', name: 'F_OrderId', width: 80, align: 'left' },
                { label: '答题总数', name: 'F_AnswerCont', width: 80, align: 'left' },
                { label: '选项数', name: 'F_OptionCont', width: 80, align: 'left' },
                { label: '选项1', name: 'F_Option1', width: 80, align: 'left' },
                { label: '选项2', name: 'F_Option2', width: 80, align: 'left' },
                { label: '选项3', name: 'F_Option3', width: 80, align: 'left' },
                { label: '选项4', name: 'F_Option4', width: 80, align: 'left' },
                { label: '选项5', name: 'F_Option5', width: 80, align: 'left' },
                { label: '选项6', name: 'F_Option6', width: 80, align: 'left' },
                { label: '选项7', name: 'F_Option7', width: 80, align: 'left' },
                { label: '选项8', name: 'F_Option8', width: 80, align: 'left' },
                { label: '选项9', name: 'F_Option9', width: 80, align: 'left' },
                { label: '选项10', name: 'F_Option10', width: 80, align: 'left' },
                {
                    label: '创建时间', name: 'F_CreatorTime', width: 100, align: 'left',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' }
                }
            ],
            pager: "#gridPager",
            sortname: 'F_OrderId asc',
            viewrecords: true
        });
    }
    function btn_details(type) {
        var keyValue = $("#gridList").jqGridRowValue().F_QuestionId;
        $.modalOpen({
            id: "Details",
            title: "图形分析",
            url: "/Questionnaire/QnQuestion/StatisticsDetails?keyValue=" + keyValue + "&type=" + type,
            width: "650px",
            height: "600px",
            btn: null,
        });
    }
    function btn_download() {
        $.download("/Questionnaire/QnQuestion/DownloadStatistics", { pid: '@pid' });
    }
</script>
<div id="parentInfo" style="padding:0 10px 0 10px;">
    <form id="form1">
        <table class="form">
            <tr>
                @*<th class="formTitle">编号</th>
                    <td class="formValue">
                        <input id="F_Id" name="F_Id" type="text" class="form-control required" placeholder="" readonly="readonly" />
                    </td>*@
                <th class="formTitle">问卷标题</th>
                <td class="formValue">
                    <input id="F_Title" name="F_Title" type="text" class="form-control required" placeholder="" readonly="readonly" />
                </td>
            </tr>
        </table>
    </form>
</div>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            @*<a id="NF-add" authorize2="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新建</a>*@
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-Details" authorize2="yes" onclick="btn_details(1)"><i class="fa fa-search-plus"></i>柱状图分析</a></li>
                <li><a id="NF-Details" authorize2="yes" onclick="btn_details(2)"><i class="fa fa-search-plus"></i>仪表盘图分析</a></li>
                <li><a id="NF-Details" onclick="btn_download()"><i class="fa fa-download"></i>统计结果下载</a></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>